﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using AuditModel;
using System.Linq;

namespace AuditWeb.Models
{
    

    public class ChangePasswordModel
    {
        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "CurrentPassword", ResourceType=typeof(AuditResources.Account))]
        public string OldPassword { get; set; }

        [Required]
        [StringLength(100, ErrorMessageResourceName = "PasswordErrorMessage", ErrorMessageResourceType = typeof(AuditResources.Account), MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "NewPassword", ResourceType = typeof(AuditResources.Account))]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "ConfirmNewPassword", ResourceType = typeof(AuditResources.Account))]
        [Compare("NewPassword", ErrorMessageResourceName = "ConfirmPasswordErrorMessage", ErrorMessageResourceType = typeof(AuditResources.Account))]
        public string ConfirmPassword { get; set; }
    }

    public class ProfileModel
    {
        AuditDBEntities db = new AuditDBEntities();
        public string CountyCode { get; set; }
        public string RealName { get; set; }
        public string Telephone { get; set; }
        public int SubjectId { get; set; }
        public string SubjectName {
            get
            {
                return  db.Subjects.SingleOrDefault(subject => subject.Id == this.SubjectId)!=null?db.Subjects.SingleOrDefault(subject => subject.Id == this.SubjectId).Name:"";
            }
        }
        public string CountyName {
            get
            {
                return db.Counties.SingleOrDefault(county => county.Code == this.CountyCode)!=null?db.Counties.SingleOrDefault(county => county.Code == this.CountyCode).Name:"";
            }
        }
        public string Username { get; set; }
        public IList<string> Roles { get; set; }
    }

    public class LogOnModel
    {
        [Required]
        [Display(Name = "Username", ResourceType = typeof(AuditResources.Account))]
        public string UserName { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "Password", ResourceType = typeof(AuditResources.Account))]
        public string Password { get; set; }

        [Display(Name = "RememberMe", ResourceType = typeof(AuditResources.Account))]
        public bool RememberMe { get; set; }
    }

    public class RegisterModel
    {
        [Required]
        [Display(Name = "Username", ResourceType = typeof(AuditResources.Account))]
        public string UserName { get; set; }

        [Required]
        [DataType(DataType.EmailAddress)]
        [Display(Name = "Email", ResourceType = typeof(AuditResources.Account))]
        public string Email { get; set; }

        [Required]
       [StringLength(100, ErrorMessageResourceName = "PasswordErrorMessage", ErrorMessageResourceType = typeof(AuditResources.Account), MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "Password", ResourceType = typeof(AuditResources.Account))]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "ConfirmPassword", ResourceType = typeof(AuditResources.Account))]
        [Compare("Password", ErrorMessageResourceName = "ConfirmPasswordErrorMessage", ErrorMessageResourceType = typeof(AuditResources.Account))]
        public string ConfirmPassword { get; set; }

        public ProfileModel Profile { get; set; }
    }

    
}
